/**
 * @Author lzc
 * @Date 2022/7/3 11:23
 */
public class Demo2 {
    public static void main(String[] args) {
        /*test1(new B() {
            @Override
            public String fun(User user) {
                return user.getName();
            }
        });*/
        
//        test1(user -> user.getName());
        test1(User::getName);  // _._1
    }
    
    public static void test1(B b) {
        String name = b.fun(new User("zs"));
        System.out.println(name);
    }
    
}


interface B {
    String fun(User user);
}

class User {
    private String name;
    
    
    public User() {
    }
    
    public User(String name) {
        this.name = name;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
}